<?php
/**
 * Mailview
 * http://code.google.com/p/mailview/
 * Martin Tournoij <martin@arp242.net>
 * Mailview is free for any use, there are no restrictions.
 */
include('mailview2.php');
$mailview = new Mailview2();

### Save
if (isset($_POST) and count($_POST) > 0)
{
	foreach ($_POST as $k => $v)
	{
		if ($v === 'on')
			$v = True;
		$_SESSION['config']["$k"] = $v;
	}

	if (!isset($_POST['allfolders']))
		$_SESSION['config']['allfolders'] = False;

	if (!isset($_POST['autoexpunge']))
		$_SESSION['config']['autoexpunge'] = False;

	Redirect();
	exit(0);
}

$link = Mailview\imap_open($_SESSION['config']);

$vars = array(
	'config' => $_SESSION['config'],
);

$mailview->Template($vars, $link);
?>
